/*LICENSE_BEGIN
 * ******************************************************************
 * Copyright 2006 by the Dainamite Robocup-Team at the
 * DAI-Labor, TU-Berlin (www.dai-labor.de)
 * 
 * Members of Dainamite are:
 * Holger Endert
 * Robert Wetzker
 * Thomas Karbe
 * Axel Heßler
 * Philippe Bütter
 * Felix Brossmann
 * 
 * Licensed under the GNU GPL (General Public License) Free Software 
 * License, Version 2. You may use this file only in compliance with 
 * the License. You may obtain a copy of the License at:
 * 
 * http://www.fsf.org/licensing/licenses/gpl.txt
 * ******************************************************************
LICENSE_END*/
package robocup.component.actions;

import robocup.component.math.RCMath;

/**
 * A kick action is used for player-agents to accelerate the ball.
 */
public class KickAction extends Action {
	
	/**
	 * The kick-power, which can be used. Lies within [0,100].
	 */
	private double _power;

	/**
	 * The direction (relative to the player, in which the ball should be 
	 * kicked. Any direction is possible (-180,180].
	 */
	private double _direction;

	/**
	 * Constructor, sets a sepcific kick-command
	 * 
	 * @param power
	 *            the power of the kick [0,100]
	 * @param direction
	 *            the angle of the kick (-180,180]
	 */
	public KickAction(double power, double direction) {
		this._type = TYPE.KICK;
		this._power = RCMath.round(power, Action.PARAMETER_PRECISION);
		this._direction = RCMath.round(direction, Action.PARAMETER_PRECISION);
	}

	/**
	 * Returns the actions string representation:
	 * @return 
	 * (kick &lt;power&gt; &lt;direction&gt;)<br><br>
	 */
	@Override
	public String toString() {
		StringBuffer buf = new StringBuffer();
		buf.append("(kick ");
		buf.append(this._power);
		buf.append(" ");
		buf.append(this._direction);
		buf.append(")");
		return buf.toString();
	}

	/**
	 * @return Returns the direction.
	 */
	public double getDirection() {
		return this._direction;
	}

	/**
	 * An action is worth sending if it effects the world.
	 * @return true, if the power is greater 0.
	 */
	@Override
	public boolean isWorthSending() {
		return this._power > 0;
	}

	/**
	 * @return Returns the power.
	 */
	public double getPower() {
		return this._power;
	}

}
